<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/html/axios.min.js"></script>
    <script>
        //使用同步方式解决异步问题
        async function getNum() {
            let num = 0;
            await axios.get("/test/getX").then(e => {
                // alert(e.data);
                num = e.data;
            })
            alert(num);
        }

        function getInfo() {
            axios.get("/test/getString").then(e => {
                alert(e.data);
            })
        }
    </script>
</head>
<body>

<input type="button" value="得到按钮" onclick="getInfo()">


<input type="button" value="得到x" onclick="getNum()">

</body>
</html>